package com.seuic.hnjiningposapp.hnapps.ui.activity;//package com.seuic.hnjiningposapp.hnapps.project;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.ToastUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BasePopupView;
import com.seuic.hnjiningposapp.R;
import com.seuic.hnjiningposapp.hnapps.SquareLayout;
import com.seuic.hnjiningposapp.hnapps.base.BaseActivity;
import com.seuic.hnjiningposapp.hnapps.bean.DqBean;
import com.seuic.hnjiningposapp.hnapps.bean.HqBean;
import com.seuic.hnjiningposapp.hnapps.bean.LlBean;
import com.seuic.hnjiningposapp.hnapps.bean.SpBean;
import com.seuic.hnjiningposapp.hnapps.bean.ZzhBean;
import com.seuic.hnjiningposapp.hnapps.ui.view.dialog.AutomaticOperationPopup;
import com.seuic.hnjiningposapp.hnapps.ui.view.dialog.ErrorPopup;
import com.seuic.hnjiningposapp.hnapps.ui.view.dialog.InputPasswordPopup;
import com.seuic.hnjiningposapp.hnapps.ui.view.dialog.QuerybalancePp;
import com.seuic.hnjiningposapp.hnapps.ui.view.dialog.ReadCardPopup;
import com.seuic.hnjiningposapp.hnapps.ui.view.dialog.RetesQueryPopup;
import com.seuic.hnjiningposapp.hnapps.ui.view.dialog.VerifyCardPopup;
import com.seuic.hnjiningposapp.hnapps.util.GetMoneyLvUtils;
import com.seuic.hnjiningposapp.hnapps.util.HttpUtils;
import com.seuic.hnjiningposapp.hnapps.util.HttpUtilsV2;
import com.seuic.hnjiningposapp.hnapps.util.MoneyUtil;
import com.seuic.hnjiningposapp.hnapps.util.MoneyUtils;
import com.seuic.hnjiningposapp.hnapps.util.PrintUtil;
import com.seuic.hnjiningposapp.hnapps.util.SelTimePickerUtil;
import com.seuic.hnjiningposapp.hnapps.util.SoftHideKeyBoardUtil;
import com.seuic.posdsdk.pos_func.PosFuncs;
import com.socks.library.KLog;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 查询业务
 */
public class QuiryBusinessActivity extends BaseActivity implements ErrorPopup.OnFinishCallbacked, QuerybalancePp.OnFinishCallBack, InputPasswordPopup.ClickCallback {
    //定期明细查询 查询类型
    boolean time_search = true;
    @BindView(R.id.card_num_tv)
    TextView cardNumTv;
    @BindView(R.id.card_name_tv)
    TextView cardNameTv;
    @BindView(R.id.numtype_tv)
    TextView numtypeTv;
    @BindView(R.id.query_sun_recyclerview)
    RecyclerView querySunRecyclerview;
    @BindView(R.id.query_sun_nobtn)
    Button querySunNobtn;
    @BindView(R.id.query_sun_okbtn)
    Button querySunOkbtn;
    @BindView(R.id.query_sun_layout)
    CardView querySunLayout;
    @BindView(R.id.decard_name_tv)
    TextView decardNameTv;
    @BindView(R.id.depennum_tv)
    TextView depennumTv;
    @BindView(R.id.starttime_tv)
    TextView starttimeTv;
    @BindView(R.id.endtime_tv)
    TextView endtimeTv;
    @BindView(R.id.dequery_sun_recyclerview)
    RecyclerView dequerySunRecyclerview;
    @BindView(R.id.dequery_sun_nobtn)
    Button dequerySunNobtn;
    @BindView(R.id.dequery_sun_okbtn)
    Button dequerySunOkbtn;
    @BindView(R.id.edquery_sun_layout)
    CardView edquerySunLayout;
    @BindView(R.id.de_query_btn)
    Button deQueryBtn;
    @BindView(R.id.dh_title)
    TextView dhTitle;
    @BindView(R.id.search_type)
    TextView searchType;
    @BindView(R.id.input_pen_numed)
    EditText inputPenNumed;
    @BindView(R.id.starttime_layout)
    RelativeLayout starttimeLayout;
    @BindView(R.id.endtime_layout)
    RelativeLayout endtimeLayout;
    @BindView(R.id.card_num_tv_lef)
    TextView cardNumTvLeft;
    @BindView(R.id.query_special_btn)
    SquareLayout querySpecialBtn;
    @BindView(R.id.sp_name)
    TextView spName;
    @BindView(R.id.current_balance)
    TextView currentBalance;
    @BindView(R.id.financial_balance)
    TextView financialBalance;
    @BindView(R.id.sp_layout)
    RelativeLayout spLayout;
    private int MAKE_TYPE = 0;
    //余额查询
    private final int MAKE_YE = 1;
    //利率查询
    private final int MAKE_LL = 2;
    //子账户查询
    private final int MAKE_ZZH = 3;
    //活期明细
    private final int MAKE_HQMX = 4;
    //定期明细
    private final int MAKE_DQMX = 5;
    //特色业务
    private final int MAKE_TSYW = 6;

    @BindView(R.id.base_back_btn)
    LinearLayout baseBackBtn;
    @BindView(R.id.base_title_text)
    TextView baseTitleText;
    @BindView(R.id.query_balance_btn)
    SquareLayout queryBalanceBtn;
    @BindView(R.id.query_interestrate_btn)
    SquareLayout queryInterestrateBtn;
    @BindView(R.id.query_son_btn)
    SquareLayout querySonBtn;
    @BindView(R.id.query_dueondemand_btn)
    SquareLayout queryDueondemandBtn;
    @BindView(R.id.query_atfixedperiod_btn)
    SquareLayout queryAtfixedperiodBtn;
    @BindView(R.id.inquiry_business_home_layout)
    LinearLayout inquiryBusinessHomeLayout;
    @BindView(R.id.home_query_layout)
    CardView homeQueryLayout;
    private PosFuncs posFuncs;
    //银行卡号
    String card_num;
    String CardType;
    private String track2Data;
    private String track3Data;
    private String s_number;
    private String Field55;
    private ReadCardPopup readcardPop;
    private BasePopupView readcardPopupView;
    private VerifyCardPopup verifycardPop;
    private BasePopupView verifycardPopupView;
    private InputPasswordPopup inputpasswordPop;
    private BasePopupView inputpasswordPopupView;
    private RetesQueryPopup retesQueryPop;
    private BasePopupView retesQueryPopupView;
    private BaseActivity baseActivity;
    private AutomaticOperationPopup automaticOperationPopup;
    private BasePopupView automaticOperationPopupView;
    private QuerybalancePp querybalancePp;
    private BasePopupView querybalancePpView;
    private ErrorPopup errorPopup;
    private BasePopupView errorPopupPpView;
    //利率数据
    List<LlBean.RateInfoBean> newrateInfoBeans = new ArrayList<>();
    @BindView(R.id.interest_rates_recyclerview)
    RecyclerView interestRatesRecyclerview;
    @BindView(R.id.interest_rates_query_okbtn)
    Button interestRatesQueryOkbtn;
    @BindView(R.id.interest_rates_query_layout)
    RelativeLayout interestRatesQueryLayout;
    private LLAdapter llAdapter;
    private ZZHAdapter zzhAdapter;

    private HqAdapter hqAdapter;
    private DqApter dqApter;
    private SpAdapter spAdapter;
    //加密的到的密码密文
    private String cipassword;
    //用户名
    private String card_username;
    private String userBalance;

    //查询出来的  子账户
    private List<ZzhBean> zzhBeans = new ArrayList<>();
    //选择了查询的账户状态的
    private List<ZzhBean> newzzhBeans;
    //活期明细
    List<HqBean> hqBeans = new ArrayList<>();
    //特殊业务
    private List<SpBean> spbeans;
    //特殊业务
    private List<SpBean> newspBeans;

    private List<DqBean> dqBeans = new ArrayList<>();


    @Override
    public int initView(Bundle savedInstanceState) {
        return R.layout.activity_quiry_business;
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        this.setBackBtClick(R.id.base_back_btn);
        this.setTitleText("查询业务");
        findViewById(R.id.base_back_btn).setVisibility(View.INVISIBLE);
        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);//设置软键盘弹出遮盖其他布局
        errorPopup = new ErrorPopup(this, this);
        errorPopupPpView = new XPopup.Builder(this)
                .dismissOnBackPressed(false)
                .dismissOnTouchOutside(false)
                .moveUpToKeyboard(false)
                .isRequestFocus(false)
                .hasShadowBg(false)
                .hasStatusBarShadow(false)
                .asCustom(errorPopup);
        querybalancePp = new QuerybalancePp(this, this);
        //验证账户信息界面
        querybalancePpView = new XPopup.Builder(this)
                .dismissOnBackPressed(false)
                .dismissOnTouchOutside(false)
                .moveUpToKeyboard(false)
                .isRequestFocus(false)
                .hasShadowBg(false)
                .hasStatusBarShadow(false)
                .asCustom(querybalancePp);
        readcardPop = new ReadCardPopup(this);
        readcardPopupView = new XPopup.Builder(this)
                .dismissOnBackPressed(false)
                .dismissOnTouchOutside(false)
                .moveUpToKeyboard(false)
                .isRequestFocus(false)
                .hasShadowBg(false)
                .hasStatusBarShadow(false)
                .asCustom(readcardPop);//验证账户信息界面
        verifycardPop = new VerifyCardPopup(this, this);
        verifycardPopupView = new XPopup.Builder(this)
                .dismissOnBackPressed(false)
                .dismissOnTouchOutside(false)
                .moveUpToKeyboard(false)
                .isRequestFocus(false)
                .hasShadowBg(false)
                .hasStatusBarShadow(false)
                .asCustom(verifycardPop);//验证账户信息界面
        inputpasswordPop = new InputPasswordPopup(this, this);
        inputpasswordPopupView = new XPopup.Builder(this)
                .dismissOnBackPressed(false)
                .dismissOnTouchOutside(false)
                .moveUpToKeyboard(false)
                .isRequestFocus(false)
                .hasShadowBg(false)
                .hasStatusBarShadow(false)
                .asCustom(inputpasswordPop);//输入密码界面
        retesQueryPop = new RetesQueryPopup(this, this);
        retesQueryPopupView = new XPopup.Builder(this)
                .dismissOnBackPressed(false)
                .dismissOnTouchOutside(false)
                .moveUpToKeyboard(false)
                .isRequestFocus(false)
                .hasShadowBg(false)
                .hasStatusBarShadow(false)
                .asCustom(retesQueryPop);//输入密码界面
    }

    @Override
    public void initEvent(Bundle savedInstanceState) {

    }

    @OnClick({R.id.interest_rates_query_okbtn, R.id.query_special_btn, R.id.search_type, R.id.de_query_btn, R.id.starttime_tv, R.id.endtime_tv, R.id.dequery_sun_nobtn, R.id.dequery_sun_okbtn, R.id.numtype_tv, R.id.query_sun_nobtn, R.id.query_sun_okbtn, R.id.query_balance_btn, R.id.query_interestrate_btn, R.id.query_son_btn, R.id.query_dueondemand_btn, R.id.query_atfixedperiod_btn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.query_balance_btn:
                //余额查询
                MAKE_TYPE = MAKE_YE;
                homeQueryLayout.setVisibility(View.GONE);
                if (!readcardPopupView.isShow()) {
                    readcardPopupView.show();
                    readcardstart();//读卡操作
                }
                break;
            case R.id.query_interestrate_btn://利率查询
                MAKE_TYPE = MAKE_LL;
                llAdapter = new LLAdapter(R.layout.ll_rv_item_layout, null);
                interestRatesRecyclerview.setLayoutManager(new LinearLayoutManager(this));
                interestRatesRecyclerview.setAdapter(llAdapter);
                interestRatesRecyclerview.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
                //进行利率查询
                HttpUtilsV2.getInterestRateInquiry(new HttpUtilsV2.NetCallBack() {
                    @Override
                    public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                        runOnUiThread(() -> {
                            String llStr = rspBody.getString("RateInfo");
                            List<LlBean.RateInfoBean> rateInfoBeans = new ArrayList<>();
                            Gson gson = new Gson();
                            rateInfoBeans = gson.fromJson(llStr, new TypeToken<ArrayList<LlBean.RateInfoBean>>() {
                            }.getType());

                            for (int i = 0; i < 7; i++) {
                                newrateInfoBeans.add(rateInfoBeans.get(i));
                            }
                            newrateInfoBeans.add(rateInfoBeans.get(10));
                            newrateInfoBeans.add(rateInfoBeans.get(11));

                            homeQueryLayout.setVisibility(View.GONE);
                            llAdapter.setNewData(newrateInfoBeans);
                            interestRatesQueryLayout.setVisibility(View.VISIBLE);
                        });

                    }

                    @Override
                    public void onError(String code, String msg) {
                        showErr(msg);
                    }
                });


                break;
            case R.id.query_son_btn:
                //子账户查询
                MAKE_TYPE = MAKE_ZZH;
                homeQueryLayout.setVisibility(View.GONE);
//                querySunLayout.setVisibility(View.VISIBLE);

                zzhAdapter = new ZZHAdapter(R.layout.query_sun_rv_itemlayout, null);
                querySunRecyclerview.setLayoutManager(new LinearLayoutManager(this));
                querySunRecyclerview.setAdapter(zzhAdapter);
                querySunRecyclerview.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));

                if (!readcardPopupView.isShow()) {
                    readcardPopupView.show();
                    readcardstart();//读卡操作
                }
                break;
            case R.id.query_dueondemand_btn:
                //活期明细查询
                MAKE_TYPE = MAKE_HQMX;
                homeQueryLayout.setVisibility(View.GONE);
                searchType.setVisibility(View.GONE);
                hqAdapter = new HqAdapter(R.layout.hq_rv_item_layout, null);
                dequerySunRecyclerview.setLayoutManager(new LinearLayoutManager(this));
                dequerySunRecyclerview.setAdapter(hqAdapter);
                dequerySunRecyclerview.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));

                if (!readcardPopupView.isShow()) {
                    readcardPopupView.show();
                    readcardstart();//读卡操作
                }
                break;
            case R.id.query_atfixedperiod_btn:
                //定期明细查询
                MAKE_TYPE = MAKE_DQMX;
                dhTitle.setText("定期明细查询");
                cardNumTvLeft.setText("卡号: ");
                homeQueryLayout.setVisibility(View.GONE);
//                edquerySunLayout.setVisibility(View.VISIBLE);
                dqApter = new DqApter(R.layout.dq_rv_item_layout, null);
                dequerySunRecyclerview.setLayoutManager(new LinearLayoutManager(this));
                dequerySunRecyclerview.setAdapter(dqApter);
                dequerySunRecyclerview.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));

                readcardtwstart();
                break;
            case R.id.query_special_btn:
                //特殊业务查询
                MAKE_TYPE = MAKE_TSYW;
                searchType.setText("全部");
                dhTitle.setText("特色业务收益查询");
                cardNumTvLeft.setText("卡号: ");
                homeQueryLayout.setVisibility(View.GONE);
//                edquerySunLayout.setVisibility(View.VISIBLE);
                spLayout.setVisibility(View.VISIBLE);
                spName.setVisibility(View.VISIBLE);
                spAdapter = new SpAdapter(R.layout.sp_rv_item_layout, null);
                dequerySunRecyclerview.setLayoutManager(new LinearLayoutManager(this));
                dequerySunRecyclerview.setAdapter(spAdapter);
                dequerySunRecyclerview.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));

                spbeans = new ArrayList<>();

                if (!readcardPopupView.isShow()) {
                    readcardPopupView.show();
                    readcardstart();//读卡操作
                }
                break;
            case R.id.numtype_tv:
                //选择 账户状态   子账户查询
                String sptypes[] = new String[]{"正常", "销户", "全部"};
                new XPopup.Builder(this)
                        .asBottomList("请选择查询状态", sptypes, (position, text) -> {
                            numtypeTv.setText(text);


                            newzzhBeans = new ArrayList<>();

                            if (text.equals("全部")) {
                                zzhAdapter.setNewData(zzhBeans);
                            } else {
                                for (int i = 0; i < zzhBeans.size(); i++) {
                                    if (String.valueOf(position).equals(zzhBeans.get(i).getFS_ACCT_STS())) {
                                        newzzhBeans.add(zzhBeans.get(i));
                                    }
                                }
                                zzhAdapter.setNewData(newzzhBeans);
                            }


                        }).show();
                break;
            case R.id.query_sun_nobtn:
//                //查询子账户成功取消
                finish();
                break;
            case R.id.query_sun_okbtn:
                //查询子账户成功 打印

                if (newzzhBeans != null) {
                    PrintUtil.PrintZZH(PosFuncs.getInstace(), 0, newzzhBeans, new PrintUtil.onPrintinterface() {
                        @Override
                        public void success(String success) {
                            ToastUtils.showLong(success);
                            finish();
                        }

                        @Override
                        public void failed(String error) {
                            ToastUtils.showLong(error);
                            finish();
                        }
                    });
                } else {
                    PrintUtil.PrintZZH(PosFuncs.getInstace(), 0, zzhBeans, new PrintUtil.onPrintinterface() {
                        @Override
                        public void success(String success) {
                            ToastUtils.showLong(success);
                            finish();
                        }

                        @Override
                        public void failed(String error) {
                            ToastUtils.showLong(error);
                            finish();
                        }
                    });
                }

                break;
            case R.id.starttime_tv:
                //选择开始时间 活期明细
                SelTimePickerUtil.loadData(this, data ->
                        starttimeTv.setText(data), "yyyyMMdd", true, true, true, false, false, false);
                SelTimePickerUtil.show();
                break;
            case R.id.endtime_tv:
                //选择结束时间 活期明细
                SelTimePickerUtil.loadData(this, data ->
                        endtimeTv.setText(data), "yyyyMMdd", true, true, true, false, false, false);
                SelTimePickerUtil.show();
                break;
            case R.id.de_query_btn:
                //查询按钮
                if (MAKE_TYPE == MAKE_TSYW) {
                    //特色业务
                    //如果是日期段查询
                    if (starttimeTv.getText().toString().equals("请选择日期")) {
                        ToastUtils.showLong("请选择开始日期");
                        return;
                    }
                    if (endtimeTv.getText().toString().equals("请选择日期")) {
                        ToastUtils.showLong("请选择结束日期");
                        return;
                    }
                    //特殊业务查询
                    doSpTodo();

                } else if (MAKE_TYPE == MAKE_DQMX) {
                    //如果是定期明细
                    if (time_search) {
                        //如果是日期段查询
                        if (starttimeTv.getText().toString().equals("请选择日期")) {
                            ToastUtils.showLong("请选择开始日期");
                            return;
                        }
                        if (endtimeTv.getText().toString().equals("请选择日期")) {
                            ToastUtils.showLong("请选择结束日期");
                            return;
                        }
                        doDqT0do("time");
                    } else {
                        //如果是笔号查询

                        if (inputPenNumed.getText().toString().equals("")) {
                            ToastUtils.showLong("请输入笔号");
                            return;
                        }
                        doDqT0do("pen");
                    }
                } else if (MAKE_TYPE == MAKE_HQMX) {
                    //如果是活期明细
                    if (starttimeTv.getText().toString().equals("请选择日期")) {
                        ToastUtils.showLong("请选择开始日期");
                        return;
                    }
                    if (endtimeTv.getText().toString().equals("请选择日期")) {
                        ToastUtils.showLong("请选择结束日期");
                        return;
                    }
                    Hqtodo();
                }
                break;
            case R.id.dequery_sun_nobtn:
                //定活期明细查询 打印
                if (MAKE_TYPE == MAKE_DQMX) {
                    //定期明细
                    PrintUtil.PrintDQMX(PosFuncs.getInstace(), 0, dqBeans, new PrintUtil.onPrintinterface() {
                        @Override
                        public void success(String success) {
                            ToastUtils.showLong(success);
                            finish();
                        }

                        @Override
                        public void failed(String error) {
                            ToastUtils.showLong(error);
                        }
                    });
                } else if (MAKE_TYPE == MAKE_HQMX) {
                    //活期明细

                    PrintUtil.PrintHQMX(PosFuncs.getInstace(), 0, hqBeans, new PrintUtil.onPrintinterface() {
                        @Override
                        public void success(String success) {
                            ToastUtils.showLong(success);
                            finish();
                        }

                        @Override
                        public void failed(String error) {
                            ToastUtils.showLong(error);
                        }
                    });
                } else if (MAKE_TYPE == MAKE_TSYW) {
                    PrintUtil.PrintSp(PosFuncs.getInstace(), 0, newspBeans, new PrintUtil.onPrintinterface() {
                        @Override
                        public void success(String success) {
                            ToastUtils.showLong(success);
                            finish();
                        }

                        @Override
                        public void failed(String error) {
                            ToastUtils.showLong(error);
                        }
                    });
                }
                break;
            case R.id.dequery_sun_okbtn:
                //定活期明细查询 确定
                finish();
                break;
            case R.id.search_type:

                if (MAKE_TYPE == MAKE_TSYW) {
                    //特色业务
                    //全部0,理财中1,已结息未入账2,已结息已入账3
                    String sptypess[] = new String[]{"全部", "理财中", "已结息未入账", "已结息已入账"};
                    new XPopup.Builder(this)
                            .asBottomList("请选择查询状态", sptypess, (position, text) -> {
                                searchType.setText(text);
                            }).show();
                } else {
                    //定期明细查询  选择查询种类
                    if (time_search) {
                        time_search = false;
                        searchType.setText("笔号查询");
                        starttimeLayout.setVisibility(View.GONE);
                        endtimeLayout.setVisibility(View.GONE);
                        inputPenNumed.setVisibility(View.VISIBLE);
                    } else {
                        time_search = true;
                        searchType.setText("时间段查询");
                        starttimeLayout.setVisibility(View.VISIBLE);
                        endtimeLayout.setVisibility(View.VISIBLE);
                        inputPenNumed.setVisibility(View.GONE);
                    }
                }
                break;
            case R.id.interest_rates_query_okbtn:
                //打印利率
                PrintUtil.printLl(PosFuncs.getInstace(), 0, newrateInfoBeans, new PrintUtil.onPrintinterface() {
                    @Override
                    public void success(String success) {
                        ToastUtils.showLong(success);
                        finish();
                    }

                    @Override
                    public void failed(String error) {
                        showErr(error);
                    }
                });
                break;

        }
    }


    /**
     * 读卡
     */
    private void readcardstart() {
        readCard(new HttpUtils.BaseReadCardListener() {
            @Override
            public void onSuccess(String data, String track2Datas) {
                card_num = data;
                track2Data = track2Datas;
                readcardPopupView.dismiss();
                verifycardPopupView.show();
                HttpUtilsV2.getCheckingThisBank(data, new HttpUtilsV2.NetCallBack() {
                    @Override
                    public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                        runOnUiThread(() -> {
                            verifycardPopupView.dismiss();
                            if (!inputpasswordPopupView.isShow()) {
                                inputpasswordPopupView.show();
                            }
                        });
                    }

                    @Override
                    public void onError(String code, String msg) {
                        showErr(msg);
                    }
                });
            }

            @Override
            public void onError(String msg) {
                showErr(msg);
            }
        });
    }

    /**
     * 读卡带密码键盘
     */
    private void readcardtwstart() {
        tradeWithCards(new HttpUtils.BaseReadCardTwListener() {
            @Override
            public void onSuccess(String data, String track2Datas, String pin) {

                card_num = data;
                track2Data = track2Datas;

                cipassword = pin;
                verifycardPopupView.show();
                HttpUtilsV2.getCheckingThisBank(data, new HttpUtilsV2.NetCallBack() {
                    @Override
                    public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                        runOnUiThread(() -> {
                            verifycardPopupView.dismiss();
                            queryother();
                        });
                    }

                    @Override
                    public void onError(String code, String msg) {
                        showErr(msg);
                    }
                });
            }

            @Override
            public void onError(String msg) {

            }
        });
    }


    private void showErr(String msg) {
        runOnUiThread(() -> {
            errorPopup.setMsg(msg);
            errorPopupPpView.show();
        });
    }

    /**
     * 验证账户信息
     */
    private void VerifyMsg() {
        if (readcardPopupView.isShow()) {
            readcardPopupView.dismiss();
            if (!verifycardPopupView.isShow()) {
                verifycardPopupView.show();
                verifycardPopupView.dismiss();
                if (!inputpasswordPopupView.isShow()) {
                    inputpasswordPopupView.show();
                }
            }
        }
    }

    @Override
    public void SendPassword(String password) {
        KLog.e("密码加密");
        KLog.e(password + "card_num" + card_num);
        cipassword = HttpUtils.getResult(password, card_num);
        inputpasswordPopupView.dismiss();

        if (MAKE_TYPE == MAKE_YE) {
            queryBalance();
        } else {
            queryother();
        }

    }

    private void queryother() {
        //弹出验证消息
        showMakeHint("验证密码...");
        HttpUtilsV2.getAccountPwdVerification(card_num, cipassword, new HttpUtilsV2.NetCallBack() {
            @Override
            public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                runOnUiThread(() -> {
                    //验证密码成功
                    dismissshowMakeHint();
                    //获取客户信息
                    showMakeHint("获取客户信息...");
                    HttpUtilsV2.getQueryBankCardInfo(card_num, new HttpUtilsV2.NetCallBack() {
                        @Override
                        public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                            card_username = rspBody.getString("AcctName");
//                            //去掉0
//                            String AvlBalance = rspBody.getString("AvlBalance").replaceFirst("^0*", "");
//                            //截取得到后两位
//                            String AvlBalance2 = AvlBalance.substring(AvlBalance.length() - 2, AvlBalance.length());
//                            //截掉后两位
//                            String Balance = AvlBalance.substring(0, AvlBalance.length() - 2);

                            userBalance = GetMoneyLvUtils.getMoney(rspBody.getString("AvlBalance"));


                            runOnUiThread(() -> {
                                dismissshowMakeHint();
                                showMakeHint("黑名单验证...");
                                HttpUtilsV2.getCheckingBankCardBlacklist(card_num, card_username, new HttpUtilsV2.NetCallBack() {
                                    @Override
                                    public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                                        runOnUiThread(() -> {
                                            dismissshowMakeHint();
                                            if (MAKE_TYPE == MAKE_ZZH) {
                                                //子账户查询
                                                zZhtodo();
                                            } else if (MAKE_TYPE == MAKE_HQMX) {
                                                //活期明细
                                                Hqtodo();
                                            } else if (MAKE_TYPE == MAKE_DQMX) {
                                                //定期明细
                                                doDqT0do("time");
                                            } else if (MAKE_TYPE == MAKE_TSYW) {
                                                doSpTodo();
                                            }
                                        });
                                    }

                                    @Override
                                    public void onError(String code, String msg) {
                                        showErr(msg);
                                    }
                                });
                            });
                        }

                        @Override
                        public void onError(String code, String msg) {
                            showErr(msg);
                        }
                    });
                });
            }

            @Override
            public void onError(String code, String msg) {
                runOnUiThread(() -> {
                    ToastUtils.showLong(msg);
                    if (MAKE_TYPE == MAKE_DQMX) {
                        finish();
                    } else {

                        dismissshowMakeHint();
                        inputpasswordPopupView = null;
                        inputpasswordPop = null;
                        inputpasswordPop = new InputPasswordPopup(QuiryBusinessActivity.this, QuiryBusinessActivity.this);
                        inputpasswordPopupView = new XPopup.Builder(QuiryBusinessActivity.this)
                                .dismissOnBackPressed(false)
                                .dismissOnTouchOutside(false)
                                .moveUpToKeyboard(false)
                                .isRequestFocus(false)
                                .hasShadowBg(false)
                                .hasStatusBarShadow(false)
                                .asCustom(inputpasswordPop);//
                        inputpasswordPopupView.show();
                    }

                });
            }
        });
    }

    /**
     * 查询余额流程
     */
    private void queryBalance() {
        //弹出验证消息
        showMakeHint("验证密码...");
        HttpUtilsV2.getAccountPwdVerification(card_num, cipassword, new HttpUtilsV2.NetCallBack() {
            @Override
            public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                runOnUiThread(() -> {
                    //验证密码成功
                    dismissshowMakeHint();
                    //获取客户信息
                    showMakeHint("获取客户信息...");
                    HttpUtilsV2.getQueryBankCardInfos(card_num, "300001", new HttpUtilsV2.NetCallBack() {
                        @Override
                        public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                            card_username = rspBody.getString("AcctName");
                            //去掉0
//                            String AvlBalance = rspBody.getString("AvlBalance").replaceFirst("^0*", "");
//                            //截取得到后两位
//                            MoneyUtil.getMoney()
//                            String AvlBalance2 = AvlBalance.substring(AvlBalance.length() - 2, AvlBalance.length());
//                            //截掉后两位
//                            String Balance = AvlBalance.substring(0, AvlBalance.length() - 2);
//
//                            userBalance = Balance + "." + AvlBalance2;
                            userBalance = GetMoneyLvUtils.getMoney(rspBody.getString("AvlBalance"));

                            runOnUiThread(() -> {
                                dismissshowMakeHint();
                                showMakeHint("黑名单验证...");
                                HttpUtilsV2.getCheckingBankCardBlacklist(card_num, card_username, new HttpUtilsV2.NetCallBack() {
                                    @Override
                                    public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                                        runOnUiThread(() -> {
                                            dismissshowMakeHint();
                                            //余额
                                            querybalancePp.setCard_balance(userBalance);
                                            querybalancePp.setCard_num(card_num);
                                            querybalancePp.setCard_username(card_username);
                                            querybalancePpView.show();

                                        });
                                    }

                                    @Override
                                    public void onError(String code, String msg) {
                                        showErr(msg);
                                    }
                                });
                            });
                        }

                        @Override
                        public void onError(String code, String msg) {
                            showErr(msg);
                        }
                    });
                });
            }

            @Override
            public void onError(String code, String msg) {
                runOnUiThread(() -> {
                    ToastUtils.showLong(msg);
                    if (MAKE_TYPE == MAKE_DQMX) {
                        finish();
                    } else {

                        dismissshowMakeHint();
                        inputpasswordPopupView = null;
                        inputpasswordPop = null;
                        inputpasswordPop = new InputPasswordPopup(QuiryBusinessActivity.this, QuiryBusinessActivity.this);
                        inputpasswordPopupView = new XPopup.Builder(QuiryBusinessActivity.this)
                                .dismissOnBackPressed(false)
                                .dismissOnTouchOutside(false)
                                .moveUpToKeyboard(false)
                                .isRequestFocus(false)
                                .hasShadowBg(false)
                                .hasStatusBarShadow(false)
                                .asCustom(inputpasswordPop);//
                        inputpasswordPopupView.show();
                    }

                });
            }
        });
    }

    public static String getMoneyType(String string) {
        // 把string类型的货币转换为double类型。
        Double numDouble = Double.parseDouble(string);
        // 想要转换成指定国家的货币格式
        NumberFormat format = NumberFormat.getCurrencyInstance(Locale.CHINA);
        // 把转换后的货币String类型返回
        String numString = format.format(numDouble);
        return numString;
    }


    /**
     * 子账户查询
     */
    private void zZhtodo() {
        showMakeHint("正在查询...");
        HttpUtilsV2.getSubAccountInformationQuerys(card_num,
                cipassword,
                "0",
                new HttpUtilsV2.NetCallBack() {
                    @Override
                    public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                        String zzhBeanstr = rspBody.getString("FS_PDT_GRP");

                        Gson gson = new Gson();

                        zzhBeans = gson.fromJson(zzhBeanstr, new TypeToken<ArrayList<ZzhBean>>() {
                        }.getType());
                        runOnUiThread(() -> {
                            dismissshowMakeHint();
                            if (zzhBeans.size() == 0) {
                                showErr("暂无数据");
                            } else {
                                querySunLayout.setVisibility(View.VISIBLE);
                                cardNumTv.setText(card_num);
                                cardNameTv.setText(card_username);
                                zzhAdapter.setNewData(zzhBeans);
                            }

                        });
                    }

                    @Override
                    public void onError(String code, String msg) {
                        showErr(msg);
                    }
                });
    }

    /**
     * 活期明细查询
     */
    private void Hqtodo() {
        String defaultStartDate = "";
        String defaultEndDate = "";
        if (starttimeTv.getText().toString().equals("请选择日期")) {
            //如果是第一次查询
            //如果是第一次查询
            //如果是第一次查询
            //如果是第一次查询
            Date dNow = new Date();   //当前时间
            Date dBefore = new Date();
            Calendar calendar = Calendar.getInstance(); //得到日历
            calendar.setTime(dNow);//把当前时间赋给日历
            calendar.add(Calendar.MONTH, -3);  //设置为前3月
            dBefore = calendar.getTime();   //得到前3月的时间
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); //设置时间格式
            defaultStartDate = sdf.format(dBefore);    //格式化前3月的时间
            defaultEndDate = sdf.format(dNow); //格式化当前时间
        } else {
            defaultStartDate = starttimeTv.getText().toString();
            defaultEndDate = endtimeTv.getText().toString();
        }


        String finalDefaultStartDate = defaultStartDate;
        String finalDefaultEndDate = defaultEndDate;
        showMakeHint("正在查询...");
        HttpUtilsV2.getAccountCurrentDetailsInquiry(card_num,
                cipassword, "1", defaultStartDate, defaultEndDate, new HttpUtilsV2.NetCallBack() {
                    @SuppressLint("SetTextI18n")
                    @Override
                    public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                        String hqBeanstr = rspBody.getString("DDP_GRP");

                        Gson gson = new Gson();
                        hqBeans = gson.fromJson(hqBeanstr, new TypeToken<ArrayList<HqBean>>() {
                        }.getType());
                        runOnUiThread(() -> {
                            dismissshowMakeHint();
                            starttimeTv.setText(finalDefaultStartDate);
                            endtimeTv.setText(finalDefaultEndDate);
                            edquerySunLayout.setVisibility(View.VISIBLE);
                            decardNameTv.setText(card_username);//姓名
                            depennumTv.setText(hqBeans.size() + "");//明细笔数
                            hqAdapter.setNewData(hqBeans);
                            if (hqBeans.size() == 0) {
                                ToastUtils.showLong("暂无数据");
                            }
                        });
                    }

                    @Override
                    public void onError(String code, String msg) {
                        showErr(msg);
                    }
                });
    }

    /**
     * 定期明细
     */
    private void doDqT0do(String type) {
        String defaultStartDate = "";
        String defaultEndDate = "";
        if (starttimeTv.getText().toString().equals("请选择日期")) {
            //如果是第一次查询
            //如果是第一次查询
            //如果是第一次查询
            //如果是第一次查询
            Date dNow = new Date();   //当前时间
            Date dBefore = new Date();
            Calendar calendar = Calendar.getInstance(); //得到日历
            calendar.setTime(dNow);//把当前时间赋给日历
            calendar.add(Calendar.MONTH, -3);  //设置为前3月
            dBefore = calendar.getTime();   //得到前3月的时间
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); //设置时间格式
            defaultStartDate = sdf.format(dBefore);    //格式化前3月的时间
            defaultEndDate = sdf.format(dNow); //格式化当前时间

        } else {
            defaultStartDate = starttimeTv.getText().toString();
            defaultEndDate = endtimeTv.getText().toString();
        }


        String sq_no = "";
        if (type.equals("time")) {
            //如果是时间查询
            sq_no = "";
        } else {
            //如果是笔号查询
            sq_no = inputPenNumed.getText().toString();
            defaultStartDate = "";
            defaultEndDate = "";
        }
        showMakeHint("正在查询...");
        HttpUtilsV2.getAccountDetailsInquiry(card_num, cipassword,
                "4",
                defaultStartDate,
                defaultEndDate, sq_no
                , track2Data, new HttpUtilsV2.NetCallBack() {
                    @Override
                    public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                        runOnUiThread(() -> {
                            dismissshowMakeHint();
                            edquerySunLayout.setVisibility(View.VISIBLE);
                            decardNameTv.setText(card_username);//姓名
                            depennumTv.setText(card_num);//卡号
                            String dqBeanstr = rspBody.getString("WK_GRPS");

                            Gson gson = new Gson();
                            dqBeans = gson.fromJson(dqBeanstr, new TypeToken<ArrayList<DqBean>>() {
                            }.getType());
                            dqApter.setNewData(dqBeans);
                            if (dqBeans.size() == 0) {
                                ToastUtils.showLong("暂无数据");
                            }
                        });
                    }

                    @Override
                    public void onError(String code, String msg) {
                        showErr(msg);
                    }
                });
    }

    /**
     * 特殊业务
     */
    private void doSpTodo() {

        String defaultStartDate = "";
        String defaultEndDate = "";
        if (starttimeTv.getText().toString().equals("请选择日期")) {
            //如果是第一次查询
            //如果是第一次查询
            //如果是第一次查询
            //如果是第一次查询
            Date dNow = new Date();   //当前时间
            Date dBefore = new Date();
            Calendar calendar = Calendar.getInstance(); //得到日历
            calendar.setTime(dNow);//把当前时间赋给日历
            calendar.add(Calendar.MONTH, -3);  //设置为前3月
            dBefore = calendar.getTime();   //得到前3月的时间
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); //设置时间格式
            defaultStartDate = sdf.format(dBefore);    //格式化前3月的时间
            defaultEndDate = sdf.format(dNow); //格式化当前时间
//


        } else {
            defaultStartDate = starttimeTv.getText().toString();
            defaultEndDate = endtimeTv.getText().toString();
        }
        showMakeHint("正在查询...");
        HttpUtilsV2.getPersonalFinancialDetailsInquiry(card_num, cipassword, defaultStartDate, defaultEndDate, new HttpUtilsV2.NetCallBack() {
            @Override
            public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                runOnUiThread(() -> {
                    dismissshowMakeHint();
                    edquerySunLayout.setVisibility(View.VISIBLE);
                    decardNameTv.setText(card_username);//姓名
                    depennumTv.setText(card_num);//卡号
                    spName.setText("");//特色业务
                    currentBalance.setText("活期余额 :" + GetMoneyLvUtils.getMoney(rspBody.getString("AcctBalance")));//活期余额
                    financialBalance.setText("理财余额 :" + GetMoneyLvUtils.getMoney(rspBody.getString("FinanceBalance")));//理财余额


                    String hqBeanstr = rspBody.getString("FinanceInfo");

                    Gson gson = new Gson();


                    spbeans = gson.fromJson(hqBeanstr, new TypeToken<ArrayList<SpBean>>() {
                    }.getType());

                    newspBeans = new ArrayList<>();

                    //全部0,理财中1,已结息未入账2,已结息已入账3

                    for (int i = 0; i < spbeans.size(); i++) {
                        if (searchType.getText().toString().equals("全部")) {
                            newspBeans.add(spbeans.get(i));
                        } else if (searchType.getText().toString().equals("理财中")) {
                            if (spbeans.get(i).getStatus().equals("1")) {
                                newspBeans.add(spbeans.get(i));
                            }
                        } else if (searchType.getText().toString().equals("已结息未入账")) {
                            if (spbeans.get(i).getStatus().equals("2")) {
                                newspBeans.add(spbeans.get(i));
                            }
                        } else if (searchType.getText().toString().equals("已结息已入账")) {
                            if (spbeans.get(i).getStatus().equals("3")) {
                                newspBeans.add(spbeans.get(i));
                            }
                        }
                    }
                    spAdapter.setNewData(newspBeans);

                });
            }

            @Override
            public void onError(String code, String msg) {
                if (code.equals("EDE32")) {
                    runOnUiThread(() -> {
                        dismissshowMakeHint();
                        edquerySunLayout.setVisibility(View.VISIBLE);
                        decardNameTv.setText(card_username);//姓名
                        depennumTv.setText(card_num);//卡号
                        spName.setText("");//特色业务
                        currentBalance.setText("活期余额 :");//活期余额
                        financialBalance.setText("理财余额 :");//理财余额


                        //全部0,理财中1,已结息未入账2,已结息已入账3


                        spAdapter.setNewData(null);
                        ToastUtils.showLong(msg);

                    });
                } else {
                    showErr(msg);
                }
            }
        });


    }


    /**
     * 查询余额成功 确定
     */
    @Override
    public void Onfinish() {
        finish();
    }

    /**
     * 错误提示
     */
    @Override
    public void finished() {
        finish();
    }


    /**
     * 利率查询
     */
    private class LLAdapter extends BaseQuickAdapter<LlBean.RateInfoBean, BaseViewHolder> {


        public LLAdapter(int layoutResId, @Nullable List<LlBean.RateInfoBean> data) {
            super(layoutResId, data);
        }

        @Override
        protected void convert(@NotNull BaseViewHolder baseViewHolder, LlBean.RateInfoBean rateInfoBean) {
            TextView sxri, ll_tv, ll_type_tv, moneytype;
            sxri = baseViewHolder.findView(R.id.sxri);
            ll_tv = baseViewHolder.findView(R.id.ll_tv);
            ll_type_tv = baseViewHolder.findView(R.id.ll_type_tv);
            moneytype = baseViewHolder.findView(R.id.moneytype);

            sxri.setText(rateInfoBean.getAvtDate());

            String text1 = rateInfoBean.getRate1().substring(2);

            String llfont = text1.substring(0, 1);

            String llqueen = text1.substring(1).replaceAll("0+$", "");


            ll_tv.setText(llfont + "." + llqueen + "%");

            ll_type_tv.setText(rateInfoBean.getRateDesc().trim());
            moneytype.setText("人民币");
        }
    }


    /**
     * 子账户查询
     */
    private class ZZHAdapter extends BaseQuickAdapter<ZzhBean, BaseViewHolder> {


        public ZZHAdapter(int layoutResId, @Nullable List<ZzhBean> data) {
            super(layoutResId, data);
        }


        @Override
        protected void convert(@NotNull BaseViewHolder baseViewHolder, ZzhBean zzhBean) {
            TextView name, num, pen, money_type, business_tv, kh_tv, open_time, stop_time, unloading, ll_tv, account_type;
            name = baseViewHolder.findView(R.id.name_tv);//账户类型
            num = baseViewHolder.findView(R.id.num_tv);//序号
            pen = baseViewHolder.findView(R.id.pen_num);//笔号
            money_type = baseViewHolder.findView(R.id.money_type);//币种
            business_tv = baseViewHolder.findView(R.id.business_tv);//余额
            kh_tv = baseViewHolder.findView(R.id.kh_tv);//开户金额
            open_time = baseViewHolder.findView(R.id.open_time);//开始时间
            stop_time = baseViewHolder.findView(R.id.stop_time);//结束时间
            unloading = baseViewHolder.findView(R.id.unloading);//自动转存
            ll_tv = baseViewHolder.findView(R.id.ll_tv);//利率
            account_type = baseViewHolder.findView(R.id.account_type);//备注

            //名称
            name.setText(zzhBean.getSA_PDP_NAME().trim());
            //序号

            num.setText(GetMoneyLvUtils.getNum(baseViewHolder.getPosition() + 1 + ""));
            //笔号
            pen.setText(zzhBean.getFS_SEQ_NO().trim());

            //币种
            money_type.setText(GetMoneyLvUtils.getZzhMoneyType(zzhBean.getFS_CURR_COD()));


            //账户余额
            //账户余额
            //账户余额
            //去掉0

            if (zzhBean.getFS_ACCT_BAL().equals("000000000000000")) {
                business_tv.setText("0.00");
            } else {

                business_tv.setText(GetMoneyLvUtils.getMoney(zzhBean.getFS_ACCT_BAL()));
            }


            //开户金额
            //开户金额
            //开户金额
            //去掉0
            if (zzhBean.getFS_OPAC_AMT().trim().equals("000000000000000")) {
                kh_tv.setText("0.00");
            } else {
                kh_tv.setText(GetMoneyLvUtils.getMoney(zzhBean.getFS_OPAC_AMT()));
            }


            //开户日期
            if (zzhBean.getFS_OPAC_DT().trim().equals("")) {
                open_time.setText("——");
            } else {
                open_time.setText(zzhBean.getFS_OPAC_DT().trim());
            }

            //到期日期
            if (zzhBean.getFS_DUE_DT().trim().equals("")) {
                stop_time.setText("——");
            } else {
                stop_time.setText(zzhBean.getFS_DUE_DT().trim());
            }

            //自动转存
            if (zzhBean.getFS_MNG_FLG().equals("1")) {
                unloading.setText("自动转存");
            } else {
                unloading.setText("非自动转存");
            }

            //利率
            //利率

            ll_tv.setText(GetMoneyLvUtils.getLv(zzhBean.getFS_INTR()));


            //账户状态
            String type = zzhBean.getFS_ACCT_STS();

            if (type.equals("0")) {
                account_type.setText("正常");
            } else if (type.equals("1")) {
                account_type.setText("销户");
            } else if (type.equals("2")) {
                account_type.setText("没收");
            } else if (type.equals("3")) {
                account_type.setText("上缴");
            } else if (type.equals("4")) {
                account_type.setText("存单存折标志");
            } else if (type.equals("5")) {
                account_type.setText("挂出");
            } else if (type.equals("6")) {
                account_type.setText("冲正");
            } else if (type.equals("7")) {
                account_type.setText("移除账户");
            }

        }
    }


    /**
     * 活期明细查询
     */
    private class HqAdapter extends BaseQuickAdapter<HqBean, BaseViewHolder> {
        public HqAdapter(int layoutResId, List<HqBean> data) {
            super(layoutResId, data);
        }

        @Override
        protected void convert(BaseViewHolder baseViewHolder, HqBean data) {
            TextView num_tv, make_time, money_type, business_tv, kh_tv, account_type;
            num_tv = baseViewHolder.findView(R.id.num_tv);//序号
            make_time = baseViewHolder.findView(R.id.make_time);//交易时间
            money_type = baseViewHolder.findView(R.id.money_type);//币种
            business_tv = baseViewHolder.findView(R.id.business_tv);//余额
            kh_tv = baseViewHolder.findView(R.id.kh_tv);//交易金额
            account_type = baseViewHolder.findView(R.id.account_type);//备注

            //序号
            num_tv.setText(GetMoneyLvUtils.getNum(baseViewHolder.getPosition() + 1 + ""));
//            交易时间
            make_time.setText(GetMoneyLvUtils.gettime(data.getTX_DT() + data.getTX_TM()));
            //币种
            money_type.setText(GetMoneyLvUtils.getMoneyType(data.getCURR_COD()));
            //余额
            business_tv.setText(GetMoneyLvUtils.getMoney(data.getDDP_ACCT_BAL()));
            //交易金额 CR +  DR-
            if (data.getCR_AMT().equals("000000000000000")) {
                kh_tv.setText("-" + GetMoneyLvUtils.getMoney(data.getDR_AMT()));
            } else {
                kh_tv.setText("+" + GetMoneyLvUtils.getMoney(data.getCR_AMT()));
            }

            //备注
            account_type.setText(data.getRMRK().trim());
        }
    }


    /**
     * 定期明细
     */
    private class DqApter extends BaseQuickAdapter<DqBean, BaseViewHolder> {
        public DqApter(int layoutResId, List<DqBean> data) {
            super(layoutResId, data);
        }

        @Override
        protected void convert(BaseViewHolder baseViewHolder, DqBean dqBean) {
            TextView num, pennum, name_tv, deal_money,
                    lx_tv, debit_and_credit, balance, save_time,
                    pay_time, account_type, digest;

            num = baseViewHolder.findView(R.id.num_tv);//序号
            pennum = baseViewHolder.findView(R.id.pen_num);//笔号
            name_tv = baseViewHolder.findView(R.id.name_tv);//名称
            deal_money = baseViewHolder.findView(R.id.deal_money);//金额
            lx_tv = baseViewHolder.findView(R.id.lx_tv);//利息
            debit_and_credit = baseViewHolder.findView(R.id.debit_and_credit);//借贷
            balance = baseViewHolder.findView(R.id.balance);//余额
            save_time = baseViewHolder.findView(R.id.save_time);//存期
            pay_time = baseViewHolder.findView(R.id.pay_time);//交易时间
            account_type = baseViewHolder.findView(R.id.account_type);//账户状态

            digest = baseViewHolder.findView(R.id.digest);//摘要

            num.setText(GetMoneyLvUtils.getNum(baseViewHolder.getPosition() + 1 + ""));

            pennum.setText(dqBean.getVOL_NO());

            name_tv.setText(dqBean.getPD_NAME().trim());
            deal_money.setText(GetMoneyLvUtils.getMoney(dqBean.getTX_AMT()));
            lx_tv.setText(GetMoneyLvUtils.getMoney(dqBean.getTAX_INT_AMT()));

            if (dqBean.getDR_CR_COD().equals("D")) {
                debit_and_credit.setText("借");
            } else {
                debit_and_credit.setText("贷");
            }
            balance.setText(GetMoneyLvUtils.getMoney(dqBean.getACCT_BAL().trim()));
            if (dqBean.getPD_NAME().trim().contains("智能存")) {
                save_time.setText("——");
            } else {
                save_time.setText(dqBean.getDEP_PRD().trim().replaceFirst("^0*", "") + "天");
            }


            pay_time.setText(GetMoneyLvUtils.gettimeNohour(dqBean.getWK_DATE()));
            account_type.setText(GetMoneyLvUtils.getAccType(dqBean.getACCT_STS().trim()));
            digest.setText(dqBean.getTD_DSCRP().trim());
        }
    }


    /**
     * 特色业务
     */
    private class SpAdapter extends BaseQuickAdapter<SpBean, BaseViewHolder> {
        public SpAdapter(int layoutResId, List<SpBean> data) {
            super(layoutResId, data);
        }

        @Override
        protected void convert(BaseViewHolder baseViewHolder, SpBean spbean) {
            TextView num_tv, licai_num, type, start_lx_time, licaimoney_tv,
                    jxmoney_tv, lcjs_num, sslv_tv, sslx_tv, jx_time, rx_time, zxll_tv, lx_tv;

            num_tv = baseViewHolder.findView(R.id.num_tv);//序号
            licai_num = baseViewHolder.findView(R.id.licai_num);//理财序号
            type = baseViewHolder.findView(R.id.type);//账户状态
            start_lx_time = baseViewHolder.findView(R.id.start_lx_time);//起息日期
            licaimoney_tv = baseViewHolder.findView(R.id.licaimoney_tv);//理财金额
            jxmoney_tv = baseViewHolder.findView(R.id.jxmoney_tv);//计息金额
            lcjs_num = baseViewHolder.findView(R.id.lcjs_num);//理财积数
            sslv_tv = baseViewHolder.findView(R.id.sslv_tv);//试算利率
            sslx_tv = baseViewHolder.findView(R.id.sslx_tv);//试算利息
            jx_time = baseViewHolder.findView(R.id.jx_time);//结息日期
            rx_time = baseViewHolder.findView(R.id.rx_time);//入账日期
            zxll_tv = baseViewHolder.findView(R.id.zxll_tv);//执行利率
            lx_tv = baseViewHolder.findView(R.id.lx_tv);//利息

            //序号
            num_tv.setText(GetMoneyLvUtils.getNum(baseViewHolder.getPosition() + 1 + ""));
            //理财序号
            licai_num.setText(spbean.getSerialNo());
            //账户状态
            type.setText(GetMoneyLvUtils.getSpType(spbean.getStatus()));
//起息日期
            start_lx_time.setText(GetMoneyLvUtils.gettimeNohour(spbean.getIntrestStartDate()));
//理财金额
            licaimoney_tv.setText("￥ " + GetMoneyLvUtils.getMoney(spbean.getDetailFinanceBalance()));
//计息金额
            jxmoney_tv.setText("￥ " + GetMoneyLvUtils.getMoney(spbean.getIntrestAmount()));
//理财积数
            lcjs_num.setText("￥ " + GetMoneyLvUtils.getMoney(spbean.getBalanceAmount()));
//试算利率
            sslv_tv.setText(GetMoneyLvUtils.getLv(spbean.getCalculateRate()));
//试算利息
            sslx_tv.setText(GetMoneyLvUtils.getMoney(spbean.getCalculateInt()));
//结息日期
            jx_time.setText(GetMoneyLvUtils.gettimeNohour(spbean.getIntrestEndDate()));
//入账日期
            rx_time.setText(GetMoneyLvUtils.gettimeNohour(spbean.getAcctDate()));
//执行利率
            zxll_tv.setText(GetMoneyLvUtils.getLv(spbean.getIntrestRate()));
//利息
            lx_tv.setText("￥ " + GetMoneyLvUtils.getMoney(spbean.getIntrest()));

        }
    }

}